{{ template "head" . }}

<h1>Consensus Top Level Metrics</h1>
{{ template "prom_right_table_head" }}
<tr>
  <th>Validators</th>
  <th>{{ template "prom_query_drilldown" (args "sum(up{job='validators'})") }} / {{ template "prom_query_drilldown" (args "count(up{job='validators'})") }}</th>
</tr>
{{ template "prom_right_table_tail" }}

{{ template "prom_content_head" . }}

<h2>Validators</h2>
{{ template "validators_table" }}

<h2>General Health</h2>
<table style="width: 90%;" cellpadding="10px">
  <tr>
    {{ template "graph_in_table" (args "lastCommittedRound" "Committed blocks per sec" "irate(consensus_gauge{op='last_committed_round'}[1m])" "blocks per sec") }}

    {{ template "graph_in_table" (args "lastCommittedVersion" "Committed successful txns per sec" "irate(consensus_gauge{op='last_committed_version'}[1m])" "txns per sec") }}

    {{ template "graph_in_table" (args "pendingBlocks" "Pending blocks" "consensus_gauge{op='num_blocks_in_tree'} - 1" "num pending blocks") }}
  </tr>
  <tr>
    {{ template "graph_in_table" (args "creationToCommit" "Avg time since block creation to commit (ms)" "irate(consensus_duration_sum{op='creation_to_commit_s'}[1m])/irate(consensus_duration_count{op='creation_to_commit_s'}[1m])" "ms") }}
  </tr>
</table>

<h2>Pacemaker</h2>
<table style="width: 90%;" cellpadding="10px">
  <tr>
    {{ template "graph_in_table" (args "qcRoundsRate" "Rounds with QC per sec" "irate(consensus{op='qc_rounds_count'}[1m])" "rounds per sec") }}

    {{ template "graph_in_table" (args "timeoutRoundsCount" "Num of timeout rounds since restart" "consensus{op='timeout_rounds_count'}" "count timeout rounds") }}

    {{ template "graph_in_table" (args "timeoutCount" "Num of timeouts since restart" "consensus{op='timeout_count'}" "count timeouts") }}
  </tr>
  <tr>
    {{ template "graph_in_table" (args "roundTimeoutVal" "Round timeout val (ms)" "consensus_gauge{op='round_timeout_ms'}" "timeout val (ms)") }}
  </tr>
</table>

<h2>Synchronization Manager</h2>
<table style="width: 90%;" cellpadding="10px">
  <tr>
    {{ template "graph_in_table" (args "syncMgrCount" "State sync since restart" "consensus{op='state_sync_count'}" "count") }}

    {{ template "graph_in_table" (args "txnsReplayedCount" "Txns replayed in state synchronization" "consensus{op='state_sync_txns_replayed'}" "txns count") }}

    {{ template "graph_in_table" (args "syncDuration" "Total time spent on state sync (ms)" "consensus_duration_sum{op='state_sync_duration_s'}" "total time spent (ms)") }}
  </tr>
  <tr>
    {{ template "graph_in_table" (args "blockRetrievalCount" "Block retrieval requests since restart" "consensus{op='block_retrieval_count'}" "count") }}

    {{ template "graph_in_table" (args "blockRetrievalDuration" "Total time spent on block retrieval (ms)" "consensus_duration_sum{op='block_retrieval_duration_s'}" "total time spent (ms)") }}
  </tr>
</table>

{{ template "prom_content_tail" . }}

{{ template "tail" }}
